/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.interfaces.major.Armature;
import ru.jSkyRoom.interfaces.major.Race;
import ru.jSkyRoom.interfaces.sub.ArmatureGenderSettings;
import ru.jSkyRoom.interfaces.sub.JSkyBodyTemplate;
import ru.jSkyRoom.interfaces.stub.JSkySound;
import skyproc.ARMA;
import skyproc.BodyTemplate;
import skyproc.FormID;
import skyproc.genenums.Gender;

/**
 *
 * @author Rakev
 */
public class ArmatureBridge extends MajorBridge<ARMA> implements Armature {

    public ArmatureBridge(ARMA adapting) {
        super(adapting);
    }

    @Override
    public Race getRace() {
        FormID id = getRawObject().getRace();
        return getFinderFactory().createRaceFinder().find(id);
    }

    @Override
    public void setRace(Race race) {
        FormID id = getIdProducer().produce(race);
        getRawObject().setRace(id);
    }

    @Override
    public Collection<Race> getAdditionalRaces() {
        Collection<FormID> ids = getRawObject().getAdditionalRaces();
        Collection<Race> races = getFinderFactory().createRaceFinder().find(ids);
        return Collections.unmodifiableCollection(races);
    }

    @Override
    public void addAdditionalRace(Race race) {
        getRawObject().addAdditionalRace(race.getForm());
    }

    @Override
    public void removeAdditionalRace(Race race) {
        getRawObject().removeAdditionalRace(race.getForm());
    }

    @Override
    public JSkySound getFootstepSound() {
        FormID soundId = getRawObject().getFootstepSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setFootstepSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setFootstepSound(id);
    }

    @Override
    public int getDetectionSoundValue() {
        return getRawObject().getDetectionSoundValue();
    }

    @Override
    public void setDetectionSoundValue(int value) {
        getRawObject().setDetectionSoundValue(value);
    }

    @Override
    public float getWeaponAdjust() {
        return getRawObject().getWeaponAdjust();
    }

    @Override
    public void setWeaponAdjust(float adjust) {
        getRawObject().setWeaponAdjust((float) adjust);
    }

    @Override
    public boolean getFlag(BodyTemplate.GeneralFlags flag) {
        return getRawObject().getBodyTemplate().get(flag);
    }

    @Override
    public void setFlag(BodyTemplate.GeneralFlags flag) {
        getRawObject().getBodyTemplate().set(flag, true);
    }

    @Override
    public void unsetFlag(BodyTemplate.GeneralFlags flag) {
        getRawObject().getBodyTemplate().set(flag, false);
    }

    @Override
    public JSkyBodyTemplate getBodyTemplate(BodyTemplate.BodyTemplateType type) {
        BodyTemplate bodyTemplate = getRawObject().getBodyTemplate();
        return getBridgeFactory().createBridge(bodyTemplate);
    }

    @Override
    public ArmatureGenderSettings getGenderSettings(Gender gender) {
        return getBridgeFactory().createGenderSettingsBridge(this, gender);
    }
}
